import Taro from "@tarojs/taro";
import {AtButton} from "taro-ui";
import {View , Image} from "@tarojs/components";
import {getBestQuestionResult} from "../../utils/bizUtil";

import Footer from "../../components/Footer/index";
import questions from '../../data/Question.json'
import question_results from '../../data/Question-result.json'

import './index.scss'


const answerList = Taro.getStorageSync('answerList')
if(answerList||answerList.length<1){
  Taro.showToast({
    title: '答案列表为空',
    icon: 'error',
    duration: 2000
  })
}


const result  = getBestQuestionResult(answerList, questions, question_results)

/**
 * 结果页面
 */
export default () => {
  return <View className='resultPage'>
    <View className='at-article__h1 title'>
      {result.resultName}
    </View>
    <View className='at-article__h3 subTitle'>{result.resultDesc}</View>
    <AtButton type='primary' circle className='enterBtn' onClick={()=>{
      Taro.reLaunch({
        url: '/pages/index/index',
      })
    }}
    >返回主页</AtButton>
    <Image src='../../assets/index.jpg' className='hearderBg'></Image>
    <Footer />
  </View>
}
